load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")

package(default_visibility = ["//rs:ic-os-pkg"])

DEPENDENCIES = [
    # Keep sorted.
    "//rs/ic_os/config_types",
    "@crate_index//:anyhow",
    "@crate_index//:macaddr",
    "@crate_index//:serde",
    "@crate_index//:serde_json",
    "@crate_index//:url",
]

rust_library(
    name = "config_types_compatibility_lib",
    srcs = glob(
        ["src/**/*.rs"],
        exclude = ["src/main.rs"],
    ),
    crate_name = "config_types_compatibility_lib",
    visibility = ["//rs:ic-os-pkg"],
    deps = DEPENDENCIES,
)

filegroup(
    name = "config_types_fixtures",
    srcs = glob(["fixtures/**/*"]),
    visibility = ["//visibility:public"],
)

rust_binary(
    name = "generate_config_types_fixture",
    srcs = ["src/main.rs"],
    crate_name = "generate_config_types_fixture",
    visibility = ["//rs:ic-os-pkg"],
    deps = [
        ":config_types_compatibility_lib",
        "//rs/ic_os/config_types",
        "@crate_index//:anyhow",
    ],
)

# Main test target for running compatibility tests
rust_test(
    name = "compatibility_tests",
    srcs = ["tests/compatibility_tests.rs"],
    crate_name = "compatibility_tests",
    data = [":config_types_fixtures"],
    deps = [
        ":config_types_compatibility_lib",
        "//rs/ic_os/config_types",
        "@crate_index//:serde_json",
    ],
)
